﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace xiaolanshu
{
    public partial class 选颜色 : Form
    {
        public int red = 0, green = 0, blue = 0;

        private void red_bar_ValueChanged(object sender, EventArgs e)
        {
            color();
            red_label.Text = "紫调：" + red_bar.Value.ToString();
        }

        private void green_bar_ValueChanged(object sender, EventArgs e)
        {
            color();
            green_label.Text = "橘调：" + green_bar.Value.ToString();
        }

        private void blue_bar_ValueChanged(object sender, EventArgs e)
        {
            color();
            blue_label.Text = "粉调：" + blue_bar.Value.ToString();
        }

        private void color()
        {

            red = Math.Min(255 - (int)(0.17 * red_bar.Value), 255);
            green = Math.Min((int)((green_bar.Value * 1.65 + blue_bar.Value * 1.92 + red_bar.Value * 1.3)), 255);
            blue = Math.Min((int)((blue_bar.Value * 2.03 + red_bar.Value * 2.38)), 255);
            label1.BackColor = Color.FromArgb(red, green, blue) ;
        }

        private void confirm_Click(object sender, EventArgs e)
        {
            用户信息.color_p = red_bar.Value;
            用户信息.color_o = green_bar.Value;
            用户信息.color_pink = blue_bar.Value;
            选包装 f = new 选包装();
            f.ShowDialog();
            this.Close();
        }

        private void uiButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public 选颜色()
        {
            InitializeComponent();
        }

        private void 选颜色_Load(object sender, EventArgs e)
        {
            label1.BackColor = Color.FromArgb(255, 0, 0);
            red = red_bar.Value;
            red_label.Text = "紫调：" + red.ToString();
            green = green_bar.Value;
            green_label.Text = "橘调：" + green.ToString();
            blue = blue_bar.Value;
            blue_label.Text = "粉调：" + blue.ToString();            
        }
    }
}
